package vista;

import java.awt.Color;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.Shape;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Ellipse2D;

import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JPanel;

import controlador.ControladorJuego;

public class BotonCircular extends JButton{
	
	private Color colorFondo;
	private Shape figura;
	private int cod;
	private boolean modificable;
		
	public BotonCircular(String rotulo, Color fon){
		super(rotulo);
		modificable = true;
		colorFondo=fon;
		setContentAreaFilled(false);		
	}

	public boolean isModificable() {
		return modificable;
	}

	public void setModificable(boolean modificable) {
		this.modificable = modificable;
	}

	public Color getColorFondo() {
		return colorFondo;
	}

	public void setColorFondo(Color colorFondo) {
		this.colorFondo = colorFondo;
	}

	protected void paintComponent(Graphics g){
		if(!getModel().isArmed()){
			g.setColor(colorFondo);
		}
		else{
			g.setColor(colorFondo);
		}
		g.fillOval(0,0,getWidth()-1,getSize().height-1);
		super.paintComponent(g);
	}
	
	protected void paintBorder(Graphics g){
		g.setColor(getForeground());
		g.drawOval(0,0,getWidth()-1,getSize().height-1 );
	}

	
	public boolean contains(int x,int y){
		if(figura == null || !figura.getBounds().equals(getBounds())){
			figura = new Ellipse2D.Float(0,0,getWidth(),getHeight());
		}
		return (figura.contains(x,y));
	}

	public int getCod() {
		return cod;
	}

	public void setCod(int cod) {
		this.cod = cod;
	}
	
}
